-- @Author: 作者：无
-- @Date:   2021-10-20 05:24:14
-- @Last Modified by:   baidwwy
-- @Last Modified time: 2025-03-08 22:15:24

local 装备自选 = class()
local zts,zts1
local 可用特技={"破血狂攻","弱点击破","凝气诀","凝神诀","冥王爆杀","慈航普度","绝幻魔音","诅咒之伤","气疗术","命疗术","回魂咒","移行换影","天衣无缝","心如明镜","气归术","命归术","水清诀","冰清诀","玉清诀","晶清诀","四海升平","破血狂攻","罗汉金钟","圣灵之甲","魔兽之印","野兽之力","放下屠刀","太极护法","光辉之甲","流云诀","笑里藏刀","破碎无双"}
--local 可用特技={"凝气诀","凝神诀","冥王爆杀","慈航普度","诅咒之伤","气疗术","命疗术","气归术","命归术"}
local 可用特效={}
local 额外属性={"体质","魔力","力量","耐力","敏捷"}
local 超级五行={"金","木","水","火","土"}
local 可选造型
local 待选 = {}
	待选[1] = {"红缨枪","曲尖枪","锯齿矛","乌金三叉戟","火焰枪","墨杆金钩","玄铁矛","金蛇信","丈八点钢矛","暗夜","梨花","霹雳","刑天之逆","五虎断魂","飞龙在天","天龙破城","弑皇"}
	待选[2] = {"青铜斧","开山斧","双面斧","双弦钺","精钢禅钺","黄金钺","乌金鬼头镰","狂魔镰","恶龙之齿","破魄","肃魂","无敌","五丁开山","元神禁锢","护法灭魔","碧血干戚","裂天"}
	待选[3] = {"青铜短剑","铁齿剑","吴越剑","青锋剑","龙泉剑","黄金剑","游龙剑","北斗七星剑","碧玉剑","鱼肠","倚天","湛卢","魏武青虹","灵犀神剑","四法青云","霜冷九州","擒龙"}
	待选[4] = {"双短剑","镔铁双剑","龙凤双剑","竹节双剑","狼牙双剑","鱼骨双剑","赤焰双剑","墨玉双剑","梅花双剑","阴阳","月光双剑","灵蛇","金龙双剪","连理双树","祖龙对剑","紫电青霜","浮犀"}
	待选[5] = {"五色缎带","幻彩银纱","金丝彩带","无极丝","天蚕丝带","云龙绸带","七彩罗刹","缚神绫","九天仙绫","彩虹","流云","碧波","秋水落霞","晃金仙绳","此最相思","揽月摘星","九霄"}
	待选[6] = {"铁爪","天狼爪","幽冥鬼爪","青龙牙","勾魂爪","玄冰刺","青刚刺","华光刺","龙鳞刺","撕天","毒牙","胭脂","九阴勾魂","雪蚕之刺","贵霜之牙","忘川三途","离钩"}
	待选[7] = {"折扇","铁骨扇","精钢扇","铁面扇","百折扇","劈水扇","神火扇","阴风扇","风云雷电","太极","玉龙","秋风","画龙点睛","秋水人家","逍遥江湖","浩气长舒","星瀚"}
	待选[8] = {"细木棒","金丝魔棒","玉如意","点金棒","云龙棒","幽路引魂","满天星","水晶棒","日月光华","沧海","红莲","盘龙","降魔玉杵","青藤玉树","墨玉骷髅","丝萝乔木","醍醐"}
	待选[9] = {"松木锤","镔铁锤","八棱金瓜","狼牙锤","烈焰锤","破甲战锤","震天锤","巨灵神锤","天崩地裂","八卦","鬼牙","雷神","混元金锤","九瓣莲花","鬼王蚀日","狂澜碎岳","碎寂"}
	待选[10] = {"牛皮鞭","牛筋鞭","乌龙鞭","钢结鞭","蛇骨鞭","玉竹金铃","青藤柳叶鞭","雷鸣嗜血鞭","混元金钩","龙筋","百花","吹雪","游龙惊鸿","仙人指路","血之刺藤","牧云清歌","霜陨"}
	待选[11] = {"黄铜圈","精钢日月圈","离情环","金刺轮","风火圈","赤炎环","蛇形月","子母双月","斜月狼牙","如意","乾坤","月光双环","别情离恨","金玉双环","九天金线","无关风月","朝夕"}
	待选[12] = {"柳叶刀","苗刀","夜魔弯刀","金背大砍刀","雁翅刀","破天宝刀","狼牙刀","龙鳞宝刀","黑炎魔刀","冷月","屠龙","血刃","偃月青龙","晓风残月","斩妖泣血","业火三灾","鸣鸿"}
	待选[13] = {"曲柳杖","红木杖","白椴杖","墨铁拐","玄铁牛角杖","鹰眼法杖","腾云杖","引魂杖","碧玺杖","业焰","玉辉","鹿鸣","庄周梦蝶","凤翼流珠","雪蟒霜寒","碧海潮生","弦月"}
	待选[14] = {"硬木弓","铁胆弓","紫檀弓","宝雕长弓","錾金宝弓","玉腰弯弓","连珠神弓","游鱼戏珠","灵犀望月","非攻","幽篁","百鬼","冥火薄天","龙鸣寒水","太极流光","九霄风雷","若木"}
	待选[15] = {"琉璃珠","水晶珠","珍宝珠","翡翠珠","莲华珠","夜灵珠","如意宝珠","沧海明珠","无量玉璧","离火","飞星","月华","回风舞雪","紫金葫芦","裂云啸日","云雷万里","赤明"}
	待选[16] = {"钝铁重剑","桃印铁刃","赭石巨剑","壁玉长铗","青铜古剑","金错巨刃","惊涛雪","醉浮生","沉戟天戊","鸦九","昆吾","弦歌","墨骨枯麟","腾蛇郁刃","秋水澄流","百辟镇魂","长息"}
	待选[18] = {"素纸灯","竹骨灯","红灯笼","鲤鱼灯","芙蓉花灯","如意宫灯","玲珑盏","玉兔盏","冰心盏","蟠龙","云鹤","风荷","金风玉露","凰火燎原","月露清愁","夭桃秾李","荒尘"}
	待选[17] = {"油纸伞","红罗伞","紫竹伞","锦绣椎","幽兰帐","琳琅盖","孔雀羽","金刚伞","落梅伞","鬼骨","云梦","枕霞","碧火琉璃","雪羽穿云","月影星痕","浮生归梦","晴雪"}
	待选[19] = {{"方巾","簪子"},{"布帽","玉钗",},{"面具","梅花簪子"},{"纶巾","珍珠头带"},{"缨络丝带","凤头钗"},{"羊角盔","媚狐头饰"},{"水晶帽","玉女发冠"},{"乾坤帽","魔女发冠"},{"黑魔冠","七彩花环"},{"白玉龙冠","凤翅金翎"},{"水晶夔帽","寒雉霜蚕"},{"翡翠曜冠","曜月嵌星"},{"金丝黑玉冠","郁金流苏簪"},{"白玉琉璃冠","玉翼附蝉翎"},{"兽鬼珐琅面","鸾羽九凤冠"},{"紫金磐龙冠","金珰紫焰冠"},{"浑天玄火盔","乾元鸣凤冕"}}
	待选[21] = {{"布裙","布衣"},{"丝绸长裙","皮衣"},{"五彩裙","鳞甲"},{"龙鳞羽衣","锁子甲"},{"天香披肩","紧身衣"},{"金缕羽衣","钢甲"},{"霓裳羽衣","夜魔披风"},{"流云素裙","龙骨甲"},{"七宝天衣","死亡斗篷"},{"飞天羽衣","神谕披风"},{"穰花翠裙","珊瑚玉衣"},{"金蚕丝裙","金蚕披风"},{"紫香金乌裙","乾坤护心甲"},{"碧霞彩云衣","蝉翼金丝甲"},{"金丝蝉翼衫","金丝鱼鳞甲"},{"五彩凤翅衣","紫金磐龙甲"},{"鎏金浣月衣","混元一气甲"}}
              待选[20] = {"护身符","五色飞石","珍珠链",{"骷髅吊坠","苍魂珠"},{"江湖夜雨","九宫坠"},{"荧光坠子","高速之星"},{"风月宝链","八卦坠"},{"碧水青龙","鬼牙攫魂"},{"万里卷云","疾风之铃"},"七彩玲珑","黄玉琉佩","鸾飞凤舞","衔珠金凤佩","七璜珠玉佩","鎏金点翠佩","紫金碧玺佩","落霞陨星坠"}
	待选[22] = {"腰带","缎带","银腰带",{"水晶腰带","玉树腰带"},{"琥珀腰链","白面狼牙"},{"乱牙咬","魔童大牙"},{"攫魂铃","双魂引"},{"兽王腰带","百窜云"},{"八卦锻带","圣王坠"},"幻彩玉带","珠翠玉环","金蟾含珠","乾坤紫玉带","琉璃寒玉带","蝉翼鱼佩带","磐龙凤翔带","紫霄云芒带"}
	待选[23] = {"布鞋","牛皮靴","马靴","侠客履","神行靴","绿靴","追星踏月","九州履","万里追云履","踏雪无痕","平步青云","追云逐电","乾坤天罡履","七星逐月靴","碧霞流云履","金丝逐日履","辟尘分光履"}

function 装备自选:初始化(根)
	self.ID = 3034
	self.x = 310
	self.y = 69
	self.xx = 0
	self.yy = 0
	self.注释 = "装备自选"
	self.可视 = false
	self.鼠标 = false
	self.焦点 = false
	self.可移动 = true
	self.窗口时间 = 0
	zts = require("gge文字类").创建(nil,16,true,false,true)
	zts1 = tp.字体表.普通字体
	zts2 = require("gge文字类").创建(nil,13,true,false,true)
	tp = 根
	self.介绍文本 = 根._丰富文本(130,90)
end

function 装备自选:取名称(名称,等级)
	local x等级 = math.floor(160/10+1)
	if  名称=="武器自选礼包" then
		可选造型={}
		for i=1,18 do
			if 待选[i] then
			    for n=1,#待选[i] do
			    	if n==x等级 then
			    		table.insert(可选造型,待选[i][n])
			    	end
			    end
			end
		end
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","必中","绝杀"}
		return nil
	elseif 名称=="衣服自选礼包" then
		可选造型={}
			if 待选[21] and 待选[21][x等级] then
				可选造型=待选[21][x等级]
			end
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","神农","再生"}
		return nil
	elseif 名称=="头盔自选礼包" then
		可选造型={}
			if 待选[19] and 待选[19][x等级] then
				可选造型=待选[19][x等级]
			end
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","神农","再生"}
		return nil
	elseif 名称=="项链自选礼包" then
		可选造型 = nil
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","再生"}
		return 待选[20][x等级]
	elseif 名称=="腰带自选礼包" then
		可选造型 = nil
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","愤怒","暴怒","神农"}
		--可用特技={}
		return 待选[22][x等级]
	elseif 名称=="鞋子自选礼包" then
		可选造型 = nil
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","神农","再生"}
		return 待选[23][x等级]
	end
	-- if 等级>=160 and not _老六 then
	--     for i,v in ipairs(可用特效) do
	--     	if v=="无级别限制" then
	--     	   table.remove(可用特效, i)
	--     	end
	--     end
	-- end
end
function 装备自选:打开(类型,o)
	self.当前格子=o
	self.装备类型 = 类型
	self.等级=160
	if self.可视 then
		self.可视 = false
		self.道具 = nil
		self.造型选择 = nil
	else
		local 按钮 = tp._按钮
		local 自适应 = tp._自适应
		local 资源 = tp.资源
		local item_mc = self:取名称(类型,160)
		if item_mc ~= nil then
			if type(item_mc)=="table"  then
			   item_mc=item_mc[取随机数(1,#item_mc)]
			end
			local dj =引擎.取物品(item_mc)
			self.道具 = {名称=item_mc,介绍=dj[1]}
			self.道具.大模型 = tp.资源:载入(dj[11],"网易WDF动画",dj[13])
			self.介绍文本:清空()
	    	self.介绍文本:添加文本(dj.介绍)
		else
			self.造型选择 = 按钮.创建(自适应.创建(12,4,72,20,1,3),0,0,4,true,true,"造型选择")
		end
		table.insert(tp.窗口_,self)
		self.资源组 = {
			[0] = 自适应.创建(4,1,300,160,3,9),
			[1] = 自适应.创建(0,1,310,400,3,9),--pwd("zxxt"), --背景
			[2] = 按钮.创建(自适应.创建(12,4,55,20,1,1),0,0,4,true,true,"提交"),
			[3] = 按钮.创建(自适应.创建(18,4,16,16,4,3),0,0,4,true,true),
			[20] = 自适应.创建(5,1,140,134,3,9),
		}
		tp.运行时间 = tp.运行时间 + 1
		self.窗口时间 = tp.运行时间
	    self.可视 = true
	    local ansl = 2
	    if self.装备类型 ~= "腰带自选礼包" and self.装备类型 ~= "头盔自选礼包" and self.装备类型 ~= "项链自选礼包" and self.装备类型 ~= "鞋子自选礼包" then
	    	ansl = 4
	    end
	    for i=2,3 do
	 	self.资源组[i]:绑定窗口_(3034)
	    end
		for i=1,ansl do
			self.资源组[#self.资源组+1]=按钮.创建(自适应.创建(25,4,19,19,4,3),0,0,4,true,true),
			self.资源组[#self.资源组]:绑定窗口_(3034)
		end
		self.选中行数 =13
	end
end

function 装备自选:更新(dt)end
function 装备自选:设置造型(类型)
	local dj = 引擎.取物品(类型)
			self.道具 = {名称=类型,介绍=dj[1]}
			self.道具.大模型=tp.资源:载入(dj[11],"网易WDF动画",dj[13])
	self.介绍文本:清空()
	self.介绍文本:添加文本(self.道具.介绍)
end
function 装备自选:设置属性(类型,事件)
	if self.道具 == nil then
		tp.提示:写入("#Y/请先选择造型")
		return
	end
	if 类型 == 1 then
		self.道具.特效 = 事件
	elseif 类型 == 2 then
		self.道具.特技 = 事件
	elseif 类型 == 3 then
		self.道具.双加1 = 事件
	elseif 类型 == 4 then
		self.道具.双加2 = 事件
	end
end

function 装备自选:显示(dt,x,y)
	self.焦点=false
	self.资源组[2]:更新(x,y)
	self.资源组[3]:更新(x,y)
	if self.造型选择 ~= nil then
		self.造型选择:更新(x,y)
		if self.造型选择:事件判断() then
			tp.窗口.对话栏:文本("女人_万圣公主","造型选择","请选择装备的造型",可选造型)
		end
	end

	for i=4,#self.资源组 do
		self.资源组[i]:更新(x,y,self.道具~=nil)
	    if self.资源组[i]:事件判断() then
	    	if i==4 then
	    		tp.窗口.对话栏:文本("女人_万圣公主","装备特效","请选择装备特效",可用特效)
	    	elseif i == 5 then
	    		tp.窗口.对话栏:文本("女人_万圣公主","装备特技","请选择装备的特技",可用特技)
	    	elseif i == 6 then
	    		tp.窗口.对话栏:文本("女人_万圣公主","装备双加[1]","请选择装备的双加[1]",额外属性)
	    	elseif i == 7 then
	    		tp.窗口.对话栏:文本("女人_万圣公主","装备双加[2]","请选择装备的双加[2]",额外属性)
	    	end
	    	self.选中行数 = i-3
	    end
	end
	if self.资源组[3]:事件判断() then
		self:打开()
		return
	elseif self.资源组[2]:事件判断() then
		if self.道具 == nil then
			tp.常规提示:打开("#Y/请选择道具造型")
			return
		end
       if self.装备类型 =="鞋子自选礼包" or self.装备类型 =="腰带自选礼包" or self.装备类型 =="项链自选礼包"or self.装备类型 =="头盔自选礼包" or self.装备类型 =="衣服自选礼包" or self.装备类型 =="武器自选礼包"  then
		if self.装备类型 == "武器自选礼包" and (self.道具.特效 == nil or self.道具.特技 == nil or self.道具.双加1 == nil or self.道具.双加2 == nil) then
			tp.常规提示:打开("请选择满了再确定")
			return
		elseif self.装备类型 == "衣服自选礼包" and (self.道具.特效 == nil or self.道具.特技 == nil ) then
			tp.常规提示:打开("请选择满了再确定")
			return
        end
		if self.道具.特效 == nil then self.道具.特效 = "无级别限制" end
		if self.道具.特技 == nil then self.道具.特技 = "破血狂攻" end
		if self.道具.双加1  and self.道具.双加2 and self.道具.双加1== self.道具.双加2  then
			tp.常规提示:打开("#R不能选择同属性的双加哦！")
			return
		end
			local function 事件()
                                                local 临时={}
				临时.特效=self.道具.特效
				临时.格子=self.当前格子
				临时.名称=self.道具.名称
				临时.等级=self.等级
				临时.特技=self.道具.特技
				临时.双加2=self.道具.双加2
				临时.双加1=self.道具.双加1
				临时.道具名字=self.装备类型
				JGESDK:发送(3824,{标识=临时})
				self:打开()
				return
			end
		   tp.窗口.文本栏:载入("属性一旦选定无法更改,你确定要提交么?",nil,true,事件)
		  return
		end
    end


	self.资源组[1]:显示(self.x,self.y)
	self.资源组[0]:显示(self.x+5,self.y+20)
	self.资源组[20]:显示(self.x+5,self.y+46)
	for i=4,#self.资源组 do
	    self.资源组[i]:显示(self.x+240,self.y+160+(i-3)*30)
	end
	if self.造型选择 ~= nil then
		self.造型选择:显示(self.x+230,self.y+150)
	end
	if self.道具 ~= nil then
		self.道具.大模型:显示(self.x+15,self.y+55)
		zts:置颜色(0xFFFFFF00)
		zts:显示(self.x+115,self.y+23,self.道具.名称)
		self.介绍文本:显示(self.x+160,self.y+60)
		zts1:置颜色(0xFFFFFF00)
		zts1:显示(self.x+20,self.y+160+1*30,"【特效】： ")
		zts1:显示(self.x+20,self.y+160+2*30,"【特技】： ")
		zts1:置颜色(0xFF00FF00)
		zts1:显示(self.x+120,self.y+160+1*30,(self.道具.特效 or ""))
		zts1:显示(self.x+120,self.y+160+2*30,(self.道具.特技 or ""))
		if self.装备类型 ~= "腰带自选礼包" and self.装备类型 ~= "头盔自选礼包" and self.装备类型 ~= "项链自选礼包" and self.装备类型 ~= "鞋子自选礼包" then
			zts1:置颜色(0xFFFFFF00)
			zts1:显示(self.x+20,self.y+160+3*30,"【双加[1]】： ")
			zts1:显示(self.x+20,self.y+160+4*30,"【双加[2]】： ")
			zts1:显示(self.x+120,self.y+160+3*30,(self.道具.双加1 or ""))
			zts1:显示(self.x+120,self.y+160+4*30,(self.道具.双加2 or ""))
			zts1:置颜色(0xFF00FF00)
		end
	end
	self.资源组[2]:显示(self.x+130,self.y+365)
	self.资源组[3]:显示(self.x+297,self.y+3)
end

function 装备自选:初始移动(x,y)
	tp.运行时间 = tp.运行时间 + 1
	if not tp.消息栏焦点 then
  		self.窗口时间 = tp.运行时间
 	end
	if not self.焦点 then
		tp.移动窗口 = true
	end
	if self.鼠标 and  not self.焦点 then
		self.xx = x - self.x
		self.yy = y - self.y
	end
end

function 装备自选:开始移动(x,y)
	if self.鼠标 then
		self.x = x - self.xx
		self.y = y - self.yy


	end
end
function 装备自选:检查点(x,y)
	if self.可视 and self.资源组[1]:是否选中(x,y)  then
		return true
	else
		return false
	end
end
return 装备自选